const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async(event, context) => {
  let {_openid,realName,departmentName,groupNumber}=event
  try {
    const result = await cloud.openapi.subscribeMessage.send({
      touser:_openid, //要推送给那个用户
      page: 'pages/index/index', //要跳转到那个小程序页面
      data: {//推送的内容
        thing1: {
          value:realName
        },
        thing2:{
          value:'广师大科教'
        },
        thing3:{
          value:departmentName
        },
        phrase5:{
          value:'通过'
        },
        phone_number6:{
          value:groupNumber
        }
      },
      templateId: 'f8o5SBsIkZhkeembJWyF3nXF-CFwLGPqRWpWh-S-xZo' ,//模板id
      miniprogramState:'developer'
    })
    console.log(result.errCode)
    return result.errCode
  } catch (err) {
    console.log(err)
    return err
  }
}